package test;

import java.util.Comparator;
import sengine.CollisionDetector;
import sengine.Object2D;
import sengine.Character;
import sengine.Sprite;

/**
 *
 * @author twoodf5611
 */
public class CollisionTester {
    public static void main(String[] args) {
        CollisionDetector coldet = new CollisionDetector();
        // A character
        Sprite cha = new Character(300, 430, 20, 20);
        cha.setPhysType(Object2D.PhysicsType.MOVABLE);
        coldet.addObject(cha);
        
        coldet.update();
        System.out.println(coldet.getCollisions()); // Should be nothing
        
        // The floor
        Sprite floor = new Sprite(0, 450, 600, 20);
        floor.setPhysType(Object2D.PhysicsType.FIXED);
        coldet.addObject(floor);
        
        coldet.update();
        System.out.println(coldet.getCollisions()); // Should be character + floor
        
        // The ceiling
        Sprite ceil = new Sprite(600, 450, 300, 10);
        ceil.setPhysType(Object2D.PhysicsType.FIXED);
        coldet.addObject(ceil);
        
        // A second character
        Sprite cha2 = new Character(550, 430, 20, 20);
        cha2.setPhysType(Object2D.PhysicsType.MOVABLE);
        coldet.addObject(cha2);
        
        coldet.update();
        System.out.println(coldet.getCollisions());
    }
    
    private static class TComp implements Comparator<Sprite> {

        @Override
        public int compare(Sprite t, Sprite t1) {
            return (int) (100*(t.getX() - t.getY()));
        }
        
    }
}
